package cmarter.dev.chpt2;

import java.util.ArrayList;
import java.util.List;

import cmarter.dev.chpt2.interfaces.Predicate;

public class Utils {

	// Proper Java 8 way using predicates
	/**
	 * NOW YOU CHANGE THE OBJECT (apple) and author a corresponding predicate
	 * 
	 * **/
	public static <T> List<T> filterList(List<T> list, Predicate<T> p) {
		List<T> result = new ArrayList<T>();
		for (T e : list) {
			if (p.test(e)) {
				result.add(e);
			}
		}
		return result;
	}
	
	
	
	public static <T> void printList(List<T> list) {
		for (T e : list) {
			System.out.println(e);
		}
	}
	
	
}
